home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 265_01 / os2rdsct.c < prev    next >
Text File  |  1990-02-13  |  896b  |  42 lines

  1. /* MS OS/2 (TM) version    written by Rainer Gerhards */
  2. /* vi: set ai : */
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <fcntl.h>
  6. #include <io.h>
  7. #define  INCL_BASE
  8. #include <os2.h>
  9.  
  10. #define    SECTSIZE    512
  11.  
  12. int    rdsct(strtsect, sectbuf)
  13. int    strtsect;
  14. char    *sectbuf;
  15. {
  16. static int    filopen = 0;
  17. static int    fh;
  18. int        actcode;
  19. static long    ifsize = 100;
  20. USHORT        ret;
  21. ULONG        dummy;
  22. unsigned    byterd;
  23.  
  24. if(!filopen)
  25.     {
  26.     ret = DosOpen("A:", &fh, &actcode, (long) ((void far *) &ifsize), 0,
  27.               0x01, 0x8090, 0l);
  28.     if(ret != 0)
  29.         {
  30.         fprintf(stderr, "Can't open floppy A: - OS error %d!\n", ret);
  31.         exit(1);
  32.         /*NOTREACHED*/
  33.         }
  34.     else
  35.         filopen = 1;
  36.     }
  37. ret = DosChgFilePtr(fh, (long) SECTSIZE * strtsect, 0, &dummy);
  38. if(ret == 0)
  39.     ret = DosRead(fh, sectbuf, SECTSIZE,  &byterd);
  40. return(((ret == 0) && (byterd == SECTSIZE)) ? 0 : 1);
  41. }
  42.